home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Interactive 7
/
PC World Interactive 7.iso
/
program
/
cprog.EXE
/
EXAMPLE.C
< prev
next >
Wrap
Text File
|
1980-01-10
|
6KB
|
118 lines
/*****************************************************************************/
/* */
/* Example source code to check if this executable's logged CRC or filesize */
/* has changed. */
/* */
/* Written by Chuck Gilmore - (C)Copyright 1988, Gilmore Systems */
/* P.O. Box 3831 */
/* Beverly Hills, CA 90212 USA */
/* */
/* Voice (213) 275-8006 */
/* Data (213) 276-5263 */
/* */
/* Designed for Turbo C version 1.5 */
/* */
/* Instructions: */
/* */
/* Small model: tcc -ms example exeawars.obj */
/* makaware example.exe */
/* example */
/* */
/* Medium model: tcc -mm example exeawarm.obj */
/* makaware example.exe */
/* example */
/* */
/* Large model: tcc -ml example exeawarl.obj */
/* makaware example.exe */
/* example */
/* */
/* Huge model: tcc -mh example exeawarh.obj */
/* makaware example.exe */
/* example */
/* */
/* Compact model: tcc -mc example exeawarc.obj */
/* makaware example.exe */
/* example */
/* */
/* */
/* NOTE THE EXTRA STEPS FOR THE TINY MODEL: */
/* */
/* Tiny model: tcc -mt example exeawart.obj */
/* exe2bin example.exe example.com */
/* del example.exe */
/* makaware example.com */
/* example */
/* */
/*****************************************************************************/
#include <stdio.h>
main(argc,argv)
int argc;
unsigned char **argv;
{
int result;
FILE *f;
extern int exeaware();
printf("\nAbout to check stored values ...\n\n");
result=exeaware(argv[0]); /* call with name of THIS program (argv[0]) */
switch(result)
{
case 1:
printf("Stored CRC doesn't match - program altered!\n");
break;
case 2:
printf("Stored filesize doesn't match - program altered!\n");
break;
case 3:
printf("Stored CRC and filesize don't match - program altered!\n");
break;
case 0:
default:
printf("No changes to CRC or filesize detected - program unaltered\n");
break;
}
/*****************************************************************************/
/** NOW, Let's change the size of the file by adding a byte to the filesize **/
/** This will change both the filesize and the CRC of the file. **/
/*****************************************************************************/
printf("about to change filesize\n");
if(!(f=fopen(argv[0],"ab"))) /* open for "append, binary mode" */
{
printf("Error - Can't open \"%s\"\n",argv[0]);
exit(1);
}
putc(0,f); /* write out 1 byte */
fclose(f); /* close the file */
/***************************************************************************/
/* The following is duplicated code from above (for example purposes only) */
/***************************************************************************/
result=exeaware(argv[0]); /* call with name of THIS program (argv[0]) */
switch(result)
{
case 1:
printf("Stored CRC doesn't match - program altered!\n");
break;
case 2:
printf("Stored filesize doesn't match - program altered!\n");
break;
case 3:
printf("Stored CRC and filesize don't match - program altered!\n");
break;
case 0:
default:
printf("No changes to CRC or filesize detected - program unaltered\n");
break;
}
exit(0);
}